#include <iostream>
#include <map>

using namespace std;
static const int MAX_NUM=5;
int main() {
    std::multimap<int, int> bag;
    bag.insert(std::make_pair<int, int>(3, 3));
    bag.insert(std::make_pair<int, int>(3, 5));
    bag.insert(std::make_pair<int, int>(3, 2));
    bag.insert(std::make_pair<int, int>(3, 1));
    bag.insert(std::make_pair<int, int>(3, 4));

    std::pair<std::multimap<int, int>::iterator, std::multimap<int, int>::iterator > ret;
    ret = bag.equal_range(3);
    std::multimap<int, int>::iterator it;
    for (it = ret.first; it!= ret.second; ++it) {
        std::cout << it->second << endl;
    }

}
